cmake_minimum_required(VERSION 3.16)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
# specify cross compilers and tools
set(CMAKE_C_COMPILER /bin/arm-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER /bin/arm-linux-gnueabi-g++)
set(CMAKE_ASM_COMPILER /bin/arm-linux-gnueabi-gcc)
set(CMAKE_AR /bin/arm-linux-gnueabi-ar)
set(CMAKE_OBJCOPY /bin/arm-linux-gnueabi-objcopy)
set(CMAKE_OBJDUMP /bin/arm-linux-gnueabi-objdump)
set(SIZE /bin/arm-linux-gnueabi-size)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

# project settings
project(CLion_Test C CXX ASM)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)

add_compile_options(-g -Wall)

if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
    message(STATUS "Maximum optimization for speed")
    add_compile_options(-Ofast)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
    message(STATUS "Maximum optimization for speed, debug info included")
    add_compile_options(-Ofast -g)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
    message(STATUS "Maximum optimization for size")
    add_compile_options(-Os)
else ()
    message(STATUS "Minimal optimization, debug info included")
    add_compile_options(-Og -g)
endif ()

# 可修改
include_directories(
        Peripherals/Inc
        CMSIS/Inc
        MyLib/Inc
        U2Lib/Inc
        /usr/arm-linux-gnueabi/include
        /usr/local/opencv/opencv-4.6.0/opencv-install/include/opencv4
        )

add_definitions(
        -DGD32F450
        -DUSE_STDPERIPH_DRIVER
        )
# 可修改结束

# add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/UserApp/Smart_LED)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/UserApp/Smart_DOOR)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/UserApp/FaceTrain)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/MyLib)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/U2Lib)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Peripherals)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/CMSIS)
